﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Cat : Ship
{
    bool m_IsOpen = false;
    public GameObject m_BigBaby;
    float m_BigBabyCurPos = 0.0f;
    float m_VelocityIncrement = -0.8f;
    float m_RotationIncrement = -0.85f;
    protected new void Start()
    {
        base.Start();
    }

    // Update is called once per frame
    protected new void Update()
    {
        base.Update();

        var newPos = m_BigBaby.transform.localPosition;
        newPos.y = m_BigBabyCurPos;
        m_BigBaby.transform.localPosition = newPos;
        if (m_IsOpen)
        {
            m_BigBabyCurPos = Mathf.Clamp(m_BigBabyCurPos + (Time.deltaTime * 0.6f), 0, 0.6f);
        }
        else
        {
            m_BigBabyCurPos = Mathf.Clamp(m_BigBabyCurPos - (Time.deltaTime * 0.6f), 0, 0.6f);
        }

        if(m_BigBabyCurPos<= 0)
        {
            m_BigBaby.GetComponent<WeaponSlot>().m_FireLicense = false;
        }
    }
    public override bool LaunchSkill()
    {
        if (!base.LaunchSkill())
            return false;
        m_IsOpen = !m_IsOpen; 
        if(m_IsOpen)
        {
            m_BigBaby.GetComponent<WeaponSlot>().m_FireLicense = true;

            SideMoveMutiple += m_VelocityIncrement;
            RotationMutiple += m_RotationIncrement;
        }
        else
        {
            SideMoveMutiple -= m_VelocityIncrement;
            RotationMutiple -= m_RotationIncrement;
        }
        return true;
    }
    public override void OnChase()
    {
        if (!m_IsOpen && SkillIsReady)
            LaunchSkill();
    }
    public override void OnFight()
    {
            if (!m_IsOpen && SkillIsReady)
            LaunchSkill();
    }
    public override void OnRetreat()
    {
        if (m_IsOpen && SkillIsReady)
            LaunchSkill();
    }
}
